//package com.example.springboot1.delay;
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.stereotype.Component;
//
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//import java.util.concurrent.TimeUnit;
//
///**
// * @author ckj
// * @description TODO
// * @date 2022-09-26 15:02
// */
//
//
//@Slf4j
//@Component
//public class RedisDelayQueueRunner implements CommandLineRunner {
//    private volatile boolean destroy = false;
//    @Autowired
//    private RedisDelayQueueUtil redisDelayQueueUtil;
//    @Autowired
//    private StartDelay startDelay;
//
//
//
//
//
//    public ExecutorService initPool() {
//        return Executors.newFixedThreadPool(2);
//    }
//
//    @Override
//    public void run(String... args) throws Exception {
//
//        redisDelayQueueUtil.addDelayQueue("111", 3L, TimeUnit.SECONDS, RedisDelayQueueEnum.START.getCode());
//
//        ExecutorService executorService = this.initPool();
//        executorService.execute(() -> {
//            while (true) {
//                try {
//                    RedisDelayQueueEnum[] queueEnums = RedisDelayQueueEnum.values();
//                    for (RedisDelayQueueEnum queueEnum : queueEnums) {
//                        Object value = redisDelayQueueUtil.getDelayQueue(queueEnum.getCode());
//                        if (value != null) {
//                            RedisDelayQueueHandle redisDelayQueueHandle = SpringBeanUtils.getBean(queueEnum.getBeanId());
//                            redisDelayQueueHandle.execute(value);
//                        }
//                    }
//                } catch (InterruptedException e) {
//                    log.error("(Redis延迟队列异常中断) {}", e.getMessage());
//                }
//            }
//        });
//        log.info("(Redis延迟队列启动成功)");
//    }
//}
//
